LCD Code:
------------
Note that lcd.c is written to be wired up on PORTA in a specific fashion that
is documented in lcd.c

On some Atmels PORTA may have reserved pins or you may want to change it to a different 
port. Just go through the whole file (lcd.c) and replace:
PORTA -> PORTX
DDRA -> DDRX   where X is the port you want.

Know conflicts:
PortC on the Atmega32, and Atmega2560 have special function pins (that are enabled
  by default).

NOTE: LCD code uses the timer code in avrutil.c

Atmega128: Usually LCD is hooked up to portc so just rename lcd_PORTC.c to lcd.c



AVRUTIL.c
-----------
in avrutil.c is the following code:

You MUST change this code according to what chip you are using and the frequency.
We are setting up a 1ms timer on Timer0.

These are given as examples. You should read my code and these examples for different
models to understand what exactly you are configuring.

>We want CTC (set by WGM)
>Divide clock so that a count to 1ms fits in 8bits (set by CS0X)
  ex: (1ms)/(1/(16mhz/64)) = 250



Atmega128 @ 16mhz will look like this: (find prescaler/CS0X on P105)
void init_timer()
{
  TIFR  |= _BV(OCF0);
  TCCR0 = _BV(WGM01) | _BV(CS02); //WGM => clear TCNT0 when TCNT0 == OCR0; CS0X divides clock
  TCNT0 = 0;			
  TIMSK |= _BV(OCIE0);    	; //Enable the interrupt with will be caught by SIGNAL(...) farther down in the code
  OCR0 = 250;    		; //Match in 1ms
  sei();
}

Atmega32 @ 8mhz will look like this: (Find info on P.80)
void init_timer()
{
  TIFR  |= _BV(OCF0);
  TCCR0 = _BV(WGM01) | _BV(CS01) | _BV(CS00); //WGM => clear TCNT0 when TCNT0 == OCR0; CS0X divides clock
  TCNT0 = 0;			 
  TIMSK |= _BV(OCIE0);    	; //Enable the interrupt with will be caught by SIGNAL(...) farther down in the code
  OCR0 = 125;    		; //Match in 1ms
  sei();
}

Atmega324p @ 8mhz will look like this: (Find info on P.80)
Note: Atmega324p has psuedo dual Timer0 A and B... so you much change a few more things. Including the interupt handler

void init_timer()
{
  //TIFR  |= _BV(OCF0);
  TCCR0B = _BV(WGM01) | _BV(CS01) | _BV(CS00); //WGM => clear TCNT0 when TCNT0 == OCR0; CS0X divides clock
  TCNT0 = 0;			 
  TIMSK0 |= _BV(OCIE0B);    	; //Enable the interrupt with will be caught by SIGNAL(...) farther down in the code
  OCR0B = 125;    		; //Match in 1ms
  sei();

}

SIGNAL(SIG_OUTPUT_COMPARE0B)
{
  ms_count++;
}


Atmega256X @ 8mhz will look like this: (Find info on P.129)
Note: Atmega2560/2561 have psuedo dual Timer0 A and B... so you much change a few more things. Including the interupt handler

void init_timer()
{
  //TIFR0  |= _BV(OCF0A);
  TCCR0B = _BV(WGM01) | _BV(CS01) | _BV(CS00); //WGM => clear TCNT0 when TCNT0 == OCR0; CS0X divides clock
  TCNT0 = 0;			 
  TIMSK0 |= _BV(OCIE0B);    	; //Enable the interrupt with will be caught by SIGNAL(...) farther down in the code
  OCR0B = 125;    		; //Match in 1ms
  sei();
}

SIGNAL(SIG_OUTPUT_COMPARE0B)
{
  ms_count++;
}

